<template>
	<view>
		<view class="page">
			<image src="@/static/nursery/index/bg.png" mode="" class="bg"></image>
		</view>
		<status-bar></status-bar>
		<view class="title">幼儿学前通</view>
		<banner :bannerList="bannerList"></banner>
		<notice :noticeList="noticeList"></notice>
		<list :schoolList="schoolList" :attrList="attrList"></list>
		<bottom :tabIndex="0" :tabbarList="tabbarList"></bottom>
	</view>
</template>

<script lang="ts" setup>
	//引入
	import { ref } from 'vue';
	import { onLoad,onShow } from '@dcloudio/uni-app';
	import statusBar from '@/components/status-bar/status-bar.vue';
	import banner from '@/components/tabbar/index/banner/banner.vue';
	import notice from '@/components/tabbar/index/notice/notice.vue';
	import list from '@/components/tabbar/index/list/list.vue';
	import bottom from '@/components/footer/footer.vue';
	import { 
		getSchoolListService,
		getSchoolAttrListService,
		getBannerListService,
		getNoticeListService,
		getTabbarListService
	} from '@/api/index.js';
	
	const bannerList = ref([]);
	const schoolList = ref([]);
	const attrList = ref([]);
	const noticeList = ref([]);
	const tabbarList = ref([]);
	
	//获取学校列表
	const getSchoolList = async () => {
		const res = await getSchoolListService('');
		schoolList.value = res.data;
		// console.log('获取学校列表成功',JSON.parse(JSON.stringify(schoolList.value)));
	}
	//获取学校属性列表
	const getSchoolAttrList = async () => {
		const res = await getSchoolAttrListService();
		attrList.value = res.data
		// console.log('获取学校属性列表成功',JSON.parse(JSON.stringify(attrList.value)));
	}
	//获取轮播图列表
	const getBannerList = async () => {
		const res = await getBannerListService();
		bannerList.value = res.data;
		// console.log('获取轮播图列表成功',JSON.parse(JSON.stringify(bannerList.value)));
	}
	//获取公告列表
	const getNoticeList = async () => {
		const res = await getNoticeListService();
		noticeList.value = res.data;
		// console.log('获取公告列表成功',JSON.parse(JSON.stringify(noticeList.value)));
	}
	//获取底部栏
	const getTabbarList = async () => {
		const res = await getTabbarListService();
		tabbarList.value = res.data
		// console.log('获取底部栏成功',JSON.parse(JSON.stringify(tabbarList.value)));
	}
	
	onLoad(() => {
		// console.log('页面初始化');
		getSchoolList();
		getSchoolAttrList();
		getBannerList();
		getNoticeList();
		getTabbarList();
	})
</script>

<style lang="scss" scoped>
	.page{
		width: 100%;
		background-color: $uni-bg-color-grey;
		min-height: 100vh;
		position: absolute;
		z-index: -1;
		top: 0;left: 0;
		.bg{
			width: 100%;
			height: mp-sizing(236);
		}
	}
	.title{
		font-size: mp-sizing(22);
		font-weight: 500;
		padding: mp-sizing(15) mp-sizing(20);
	}
</style>